package com.qu.waibao.nearby;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.xlhratingbar_lib.XLHRatingBar;
import com.qu.waibao.R;
import com.qu.waibao.base.BaseRecyclerAdapter;
import com.qu.waibao.bean.ShopDetail;
import com.qu.waibao.network.NetManager;
import com.qu.waibao.utils.ImageLoader;

import butterknife.BindView;
import butterknife.ButterKnife;
import de.hdodenhof.circleimageview.CircleImageView;

/**
 * @描述 describe
 * @作者 Administrator
 * @创建时间 2018/7/25 11:00
 * @邮箱 1123599561@qq.com
 */
public class CommentAdapter extends BaseRecyclerAdapter<ShopDetail.CommentlistBean> {
    public CommentAdapter(Context context, int mode) {
        super(context, mode);
    }

    @Override
    protected RecyclerView.ViewHolder onCreateDefaultViewHolder(ViewGroup parent, int type) {
        return new CommentViewHodler(mInflater.inflate(R.layout.comment_recycler_item,parent,false));
    }

    @Override
    protected void onBindDefaultViewHolder(RecyclerView.ViewHolder holder, ShopDetail.CommentlistBean item, int position) {
        CommentViewHodler commentViewHodler  = (CommentViewHodler) holder;
        if(!TextUtils.isEmpty(item.getPhoto())){
            ImageLoader.loadImage(Glide.with(mContext),commentViewHodler.imageView, NetManager.getFullUrl(item.getPhoto()),
                    R.drawable.shjs_touxiang,R.drawable.shjs_touxiang);
        }
        commentViewHodler.tv_phone.setText(item.getSecondname());
        commentViewHodler.tv_time.setText(item.getCreatedate());
        commentViewHodler.ratingBar.setCountSelected(Integer.valueOf(item.getScore()));
        commentViewHodler.tv_content.setText(item.getRemark());
    }

    class CommentViewHodler extends RecyclerView.ViewHolder{
        @BindView(R.id.iv_photo)
        CircleImageView imageView;
        @BindView(R.id.tv_phone)
        TextView tv_phone;
        @BindView(R.id.tv_time)
        TextView tv_time;
        @BindView(R.id.tv_content)
        TextView tv_content;
        @BindView(R.id.ratingBar)
        XLHRatingBar ratingBar;
        public CommentViewHodler(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
